Initialize a new instance of the EntityListManager.
Syntax
Parameters
- entityManager
- EntityManager holding the Entities
- filter
- A predicate returning true if the tested entity belongs in the list
- filterProperties
- The watched properties. If supplied, changes to values in the watched properties trigger filtering. If null, any changes to Entities of this type will trigger filtering.
Example
C# | Copy Code |
---|
// Example showing how a List<T> can be managed as a live list.
public void EntityListManagerSample() {
DomainModelEntityManager mgr = new DomainModelEntityManager();
// Retrieve a customer and employee.
var customer = mgr.Customers.FirstOrDefault(c => c.Id == 1);
var employee = mgr.Employees.FirstOrDefault(e => e.Id == 1);
// Load a List with customer's order summaries.
var list = new List<OrderSummary>(customer.OrderSummaries);
int orderCount = list.Count;
// We want to watch for any new orders for this customer.
// We can't "watch" the NavigationEntityProperty, so watch its FK.
var prop = OrderSummary.Customer_fk_IdEntityProperty;
// Set up the manager.
IListManager manager = new EntityListManager<OrderSummary>(mgr,
os => os.Customer == customer, // filter
new[] { prop }, // watch
list, // list to be managed
false); // refresh now
// Create a new order - the list count should increment.
OrderSummary aOrder = mgr.CreateEntity<OrderSummary>();
aOrder.Employee = employee;
aOrder.Customer = customer;
aOrder.AddToManager();
Assert.IsTrue(list.Count == orderCount + 1);
// Now delete this order - the list count should decrement.
aOrder.EntityAspect.Delete();
Assert.IsTrue(list.Count == orderCount);
} |
Visual Basic | Copy Code |
---|
|
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also